feat(cache): add in flight deduping#4459
feat(cache): add in flight deduping#4459MasterPtato wants to merge 1 commit into03-18-fix_cache_clean_up_libfrom
Conversation
|
🚅 Deployed to the rivet-pr-4459 environment in rivet-frontend
|
|
Warning This pull request is not mergeable via GitHub because a downstack PR is open. Once all requirements are satisfied, merge this PR as a stack on Graphite.
This stack of pull requests is managed by Graphite. Learn more about stacking. |
175706a to
17d21f5
Compare
75e1e38 to
bc5d6d3
Compare
Code Review: feat(cache): add in-flight deduplicationThe overall approach is solid — using A few issues worth addressing before merge: Critical: Broadcast not sent when getter resolves no valuesIn if !entries_values.is_empty() {
if let Err(err) = cache.driver.set(&base_key_clone, entries_values).await {
tracing::error!(?err, "failed to write to cache");
}
let _ = broadcast_tx.send(());
}
// Release leases
for key in leased_keys {
self.cache.in_flight.remove_async(&cache_key).await;
}If the getter returns no values for the leased keys (e.g. the entities don't exist), waiting subscribers never receive the signal and block for the full if !entries_values.is_empty() {
if let Err(err) = cache.driver.set(&base_key_clone, entries_values).await {
tracing::error!(?err, "failed to write to cache");
}
}
// Always signal waiters whether or not values were written
let _ = broadcast_tx.send(());
for key in leased_keys { ... }Critical: Lease not released on getter errorIf let (ctx2, ctx3) = tokio::try_join!(...)?; // early return skips cleanup
// never reached on error:
for key in leased_keys {
self.cache.in_flight.remove_async(&cache_key).await;
}Stale entries remain in A Minor: No cleanup on future cancellationRelated to the above: if the enclosing async task is dropped while Nit:
|
bc5d6d3 to
b395fae
Compare
17d21f5 to
de18421
Compare
de18421 to
e65f84d
Compare
b395fae to
6570bf2
Compare
6570bf2 to
b46226c
Compare
e65f84d to
65200cf
Compare

Description
Please include a summary of the changes and the related issue. Please also include relevant motivation and context.
Type of change
How Has This Been Tested?
Please describe the tests that you ran to verify your changes.
Checklist: